package vistas;

import java.awt.EventQueue;

import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;

import java.awt.Toolkit;
import javax.swing.JFileChooser;
import java.awt.BorderLayout;

import javax.swing.JButton;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;

import clases.Asistencias_cargarclass;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.File;

public class Asistencias_cargarform extends JInternalFrame {

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Asistencias_cargarform dialog = new Asistencias_cargarform();
					dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
					dialog.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the dialog.
	 */
	public Asistencias_cargarform() {
		setFrameIcon(new ImageIcon(Asignarhorarios_buscarform.class.getResource("/icons/upload.png")));
		setClosable(true);
		setIconifiable(true);
		setTitle("Carga de Fichero de Asistencias");
		setBounds(100, 100, 576, 389);
		getContentPane().setLayout(null);
		
		final JFileChooser selector = new JFileChooser();
		selector.setControlButtonsAreShown(false);
		selector.setBounds(0, 0, 560, 308);
		selector.setFileFilter(new FileNameExtensionFilter("Archivos Excel (*.xls, *.xlsx)", new String[]{"xls","xlsx"}));
		getContentPane().add(selector);
		
		JButton btnCargar = new JButton("Cargar");
		btnCargar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				try
				{
					
					new Asistencias_cargarclass().cargar(selector.getSelectedFile());
				}catch(Exception ex)
				{
					JOptionPane.showMessageDialog(null, ex.toString());
				}
			}
		});
		btnCargar.setBounds(461, 319, 89, 23);
		getContentPane().add(btnCargar);

	}
}
